import java.util.Arrays;

public class Test2 {

    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer("helloworld");
        stringBuffer.append(10);
        System.out.println(stringBuffer);

        stringBuffer.setCharAt(0, 'H');
        System.out.println(stringBuffer);

        stringBuffer.insert(5, ' ');
        System.out.println(stringBuffer);

        stringBuffer.deleteCharAt(0);
        System.out.println(stringBuffer);

        System.out.println(stringBuffer.delete(0, 5));

        System.out.println(stringBuffer.reverse());
    }

    public static void main8(String[] args) {
        String string1 = new String("hello world");
        String string3 = string1.intern();
        String string2 = "hello world";
        System.out.println(string1 == string2);
        System.out.println(string2 == string3);

        char[] chars = {'h', 'i'};
        String string4 = new String(chars);
        string4.intern();
        String string5 = "hi";
        System.out.println(string4 == string5);
    }

    public static void main7(String[] args) {
        String string = "hello world";
        System.out.println(string.substring(0));
        System.out.println(string.substring(0,5));

        String string2 = "  hello world  ";
        System.out.println(string2.trim());
    }

    public static void main6(String[] args) {
        String string = "hello world hello Java";
        // String[] strings = string.split(" ");
        String[] strings = string.split(" ", 2);
        System.out.println(Arrays.toString(strings));

        String string1 = "192.168.120.15";
        String[] strings1 = string1.split("\\.");
        System.out.println(Arrays.toString(strings1));

        String string2 = "192\\168\\120\\15";
        String[] strings2 = string2.split("\\\\");
        System.out.println(Arrays.toString(strings2));
    }

    public static void main5(String[] args) {
        String s1 = "Hello World";
        String s2 = "Java BIT";
        String ret1 = s1.toLowerCase();
        String ret2 = s2.toUpperCase();
        System.out.println(ret1);
        System.out.println(ret2);

        String s3 = "hello world";
        char[] chars = s3.toCharArray();
        System.out.println(Arrays.toString(chars));

        String s4 = new String(chars);
        System.out.println(s4);

        String s5 = "helloJava";
        System.out.println(s5.replace("o", " "));
        System.out.println(s5.replace("l", "i"));
    }

    public static void main4(String[] args) {
        String s1 = String.valueOf(12);
        String s2 = String.valueOf(12.3);
        String s3 = String.valueOf(true);
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);

        int ret1 = Integer.parseInt("12345");
        double ret2 = Double.parseDouble("12.36");

        System.out.println(ret1);
        System.out.println(ret2);
    }

    public static void main3(String[] args) {
        String string = "ababcdabcabcdef";
        System.out.println(string.charAt(2));
        System.out.println(string.indexOf("abc"));
        System.out.println(string.lastIndexOf("abc",8));
        System.out.println(string.indexOf('a',3));
        System.out.println(string.lastIndexOf('e'));
    }

    public static void main2(String[] args) {
        /*int a = 10;
        int b = 20;
        int c = 10;

        System.out.println(a == b);
        System.out.println(a == c);*/

        /*String s1 = new String("hello bit");
        String s2 = new String("hello java");
        String s3 = s1;

        System.out.println(s1 == s2);
        System.out.println(s1 == s3);*/

        /*String s1 = new String("hello world");
        String s2 = new String("hello world");
        String s3 = new String("party");

        System.out.println(s1.equals(s2));
        System.out.println(s1.equals(s3));*/

        /*String s1 = new String("abc");
        String s2 = new String("ab");
        String s3 = new String("abc");
        String s4 = new String("abcdef");

        System.out.println(s1.compareTo(s2));
        System.out.println(s1.compareTo(s3));
        System.out.println(s1.compareTo(s4));*/

        String s1 = new String("abc");
        String s2 = new String("AbC");
        System.out.println(s1.compareToIgnoreCase(s2));

    }

    public static void main1(String[] args) {
        String string = "hello";
        System.out.println(string);

        String string1 = new String("world");
        System.out.println(string1);

        char[] chars = {'H','e','l','l','o'};
        String string2 = new String(chars);
        System.out.println(chars);

    }
}
